package io.osw.modules.sys.service.impl;

import io.osw.common.annotation.DataFilter;
import io.osw.common.utils.Constant;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.osw.common.utils.PageUtils;
import io.osw.common.utils.Query;

import io.osw.modules.sys.dao.TblPrBatchDao;
import io.osw.modules.sys.entity.TblPrBatchEntity;
import io.osw.modules.sys.service.TblPrBatchService;


@Service("tblPrBatchService")
public class TblPrBatchServiceImpl extends ServiceImpl<TblPrBatchDao, TblPrBatchEntity> implements TblPrBatchService {

    @Override
    @DataFilter(subDept = true, user = false)
    public PageUtils queryPage(Map<String, Object> params) {
        String batchName = (String)params.get("batchName");
        Page<TblPrBatchEntity> page = this.selectPage(
                new Query<TblPrBatchEntity>(params).getPage(),
                new EntityWrapper<TblPrBatchEntity>()
                        .like(StringUtils.isNotBlank(batchName),"batch_name", batchName)
                        .addFilterIfNeed(params.get(Constant.SQL_FILTER) != null, (String)params.get(Constant.SQL_FILTER))

        );

        return new PageUtils(page);
    }

}
